#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
struct Stu
{
	char name[10];
	size_t age;
	float score;
};
int main()
{
	char arr[10] = { "abcdefg" };
	//FILE* fp = fopen("date3.txt", "w");
	FILE* fp = fopen("date3.txt", "r");
	char arr2[10] = { 0 };
	if (fp == NULL)
	{
		perror(fopen);
		return 1;
	}
	//fwrite(arr, sizeof(char), 10, fp);
	fread(arr2, sizeof(char), 10, fp);
	puts(arr2);
	fclose(fp);
	fp = NULL;
	return 0;
}
int main2()
{
	struct Stu s = { "zhangsan",18,90.5 };
	//FILE* fp = fopen("date2.txt", "w");
	FILE* fp = fopen("date2.txt", "r");
	struct Stu s2 = { 0 };
	if (fp == NULL)
	{
		perror(fopen);
		return 1;
	}
	fscanf(fp, "%s %zd %f", s2.name, &s2.age, &s2.score);
	//fprintf(fp, "%s %zd %f", s.name, s.age, s.score);
	printf("%s %zd %f", s2.name, s2.age, s2.score);
	fclose(fp);
	fp = NULL;
	return 0;
}
int main1()
{
	FILE* pf = fopen("date1.txt", "r");
	if (pf == NULL)
	{
		perror(fopen);
		return 1;
	}
	//fputs("abceefg", pf);
	char arr[10] = { 0 };

	fgets(arr, 10, pf);
	printf("%s", arr);
	fclose(pf);
	pf = NULL;
	return 0;
}